package core.impl;


import core.ListableBeanFactory;
import util.util.CollectionUtil;

import java.util.List;
import java.util.Set;
import java.util.function.Function;

/**
 * @author Max
 * <br>
 * date 2019/12/19 14:11
 * @since 0.2
 */

public class DefaultListableBeanFactory extends DefaultBeanFactory implements ListableBeanFactory {


    @Override
    public <T> List<T> getBeans(Class<T> clazz) {
        Set<String> beanNames = super.getBeanNames(clazz);

        return CollectionUtil.toList(beanNames, s -> DefaultListableBeanFactory.super.getBean(s,clazz));

        /*return CollectionUtil.toList(beanNames, new Function<String, T>() {
            @Override
            public T apply(String s) {
                return DefaultListableBeanFactory.super.getBean(s,clazz);
            }
        });*/
    }
}